package org.example.brave.dubbo.consumer;

import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.example.service.DemoService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Service;

@SpringBootApplication
@Service
@EnableDubbo
public class BraveDubboConsumer {
    @DubboReference
    DemoService demoService;
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(BraveDubboConsumer.class, args);
        BraveDubboConsumer application = context.getBean(BraveDubboConsumer.class);
        String result = application.callDemoService("qinbiao");
        System.out.println(result);
    }

    public String callDemoService(String name) {
        return demoService.sayHello(name);
    }
}
